﻿<UserControl x:Class="GSF.PhasorProtocols.UI.UserControls.InputStatusMonitorUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="590" d:DesignWidth="850"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:uc="clr-namespace:GSF.TimeSeries.UI.UserControls;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:tsf="clr-namespace:GSF.TimeSeries.UI;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"
             xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
             Background="Transparent" >

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        
        <Grid.Resources>
            <Style TargetType="{x:Type TextBlock}">
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="TextAlignment" Value="Left"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Padding" Value="0"/>                
            </Style>

            <Style TargetType="{x:Type CheckBox}">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>                
            </Style>
                        
        </Grid.Resources>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>            
            <ColumnDefinition Width="2*"/> <!-- For Chart Display -->
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>            
            <RowDefinition Height="*"/>             
        </Grid.RowDefinitions>

        <!-- Setting PopupShowuserStatusDoc XAML Starts -->

        <tsf:TsfPopup x:Name="ShowuserStatusDoc" Topmost="False">

            <Border CornerRadius="5" BorderThickness="2" Background="White" BorderBrush="Blue">

                <Grid Margin="5">

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="45" MinWidth="1" MaxWidth="50" />
                        <ColumnDefinition Width="155" MinWidth="1" MaxWidth="165" />
                        <ColumnDefinition Width="450" MinWidth="1" MaxWidth="1005"/>
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <TextBlock Text="Bit(s)" Grid.Row="0" Grid.Column="0" FontWeight="Bold" />
                    <TextBlock Text="Description" Grid.Row="0" Grid.Column="1" FontWeight="Bold"/>
                    <TextBlock Text="Comment" Grid.Row="0" Grid.Column="2" FontWeight="Bold"/>
                    <TextBlock Text="15" Grid.Row="1" Grid.Column="0"/>
                    <TextBlock Text="Data valid" Grid.Row="1" Grid.Column="1"/>
                    <TextBlock Text="0 when PMU data is valid, 1 when invalid or PMU is in test mode." Grid.Row="1" Grid.Column="2"/>
                    <TextBlock Text="14" Grid.Row="2" Grid.Column="0"/>
                    <TextBlock Text="PMU error" Grid.Row="2" Grid.Column="1"/>
                    <TextBlock Text="including configuration error, 0 when no error." Grid.Row="2" Grid.Column="2"/>
                    <TextBlock Text="13" Grid.Row="3" Grid.Column="0"/>
                    <TextBlock Text="PMU sync" Grid.Row="3" Grid.Column="1"/>
                    <TextBlock Text="0 when in sync." Grid.Row="3" Grid.Column="2"/>
                    <TextBlock Text="12" Grid.Row="4" Grid.Column="0"/>
                    <TextBlock Text="Data sorting" Grid.Row="4" Grid.Column="1"/>
                    <TextBlock Text="0 by time stamp, 1 by arrival." Grid.Row="4" Grid.Column="2"/>
                    <TextBlock Text="11" Grid.Row="5" Grid.Column="0"/>
                    <TextBlock Text="PMU trigger detected" Grid.Row="5" Grid.Column="1"/>
                    <TextBlock Text="0 when no trigger." Grid.Row="5" Grid.Column="2"/>
                    <TextBlock Text="10" Grid.Row="6" Grid.Column="0"/>
                    <TextBlock Text="Configuration changed" Grid.Row="6" Grid.Column="1"/>
                    <TextBlock Text="set to 1 for 1 min when configuration changed." Grid.Row="6" Grid.Column="2"/>
                    <TextBlock Text="09-06" Grid.Row="7" Grid.Column="0"/>
                    <TextBlock Text="Reserved for security" Grid.Row="7" Grid.Column="1"/>
                    <TextBlock Text="presently set to 0." Grid.Row="7" Grid.Column="2"/>
                    <TextBlock Text="05-04" Grid.Row="8" Grid.Column="0"/>
                    <TextBlock Text="Unlocked time" Grid.Row="8" Grid.Column="1"/>
                    <TextBlock Text="00 = sync locked, best quality." Grid.Row="8" Grid.Column="2"/>
                    <TextBlock Text="01 = Unlocked for 10 s " Grid.Row="9" Grid.Column="2"/>
                    <TextBlock Text="10 = Unlocked for 100 s" Grid.Row="10" Grid.Column="2"/>
                    <TextBlock Text="11 = Unlocked over 1000 s" Grid.Row="11" Grid.Column="2"/>
                    <TextBlock Text="03-00" Grid.Row="12" Grid.Column="0"/>
                    <TextBlock Text="Trigger reason" Grid.Row="12" Grid.Column="1"/>
                    <TextBlock Text="1111–1000:           Available for user definition" Grid.Row="12" Grid.Column="2"/>
                    <TextBlock Text="0111: Digital                         0110: Reserved" Grid.Row="13" Grid.Column="2"/>
                    <TextBlock Text="0101: df/dt high                   0100: Frequency high/low" Grid.Row="14" Grid.Column="2"/>
                    <TextBlock Text="0011: Phase-angle diff         0010: Magnitude high" Grid.Row="15" Grid.Column="2"/>
                    <TextBlock Text="0011: 0001: Magnitude low 0000: Manual" Grid.Row="16" Grid.Column="2"/>
                    <StackPanel Orientation="Horizontal" Grid.Row="18" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right">
                        <Button Content="Cancel" Margin="0,0,5,0" Click="ButtonCancelShowuserStatusDoc_Click" IsCancel="True"/>
                    </StackPanel>
                </Grid>

            </Border>

        </tsf:TsfPopup>

        <!-- /Setting PopupShowuserStatusDoc XAML Ends -->

        <!-- Setting Popup XAML Starts -->

        <tsf:TsfPopup x:Name="PopupSettings" Topmost="False">

            <Border CornerRadius="5" BorderThickness="2" Background="White" BorderBrush="Blue">

                <Grid Margin="5">

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <TextBlock Text="Last Selected Measurements" Grid.Row="0" Grid.Column="0"/>
                    <TextBox x:Name="TextBoxLastSelectedMeasurements" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" TextWrapping="Wrap" Height="50" Width="340"/>

                    <TextBlock Text="Number of Data Points to Plot" Grid.Row="2" Grid.Column="0"/>
                    <TextBox x:Name="TextBoxNumberOFDataPointsToPlot" Grid.Row="2" Grid.Column="1" Width="50"/>
                    <TextBlock Text="Data Resolution (Frames Per Second)" Grid.Row="2" Grid.Column="2"/>
                    <TextBox x:Name="TextBoxDataResolution" Grid.Row="2" Grid.Column="3" Width="50"/>

                    <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">
                        <TextBlock Text="Lag Time" />
                        <Button Content="?" Margin="2,0,0,0" Template="{StaticResource RoundButtonTemplate}" Background="{StaticResource BlueRadialGradientBrush}" Foreground="#FFFFFF" Width="18" Height="18" FontWeight="Bold" FontSize="{StaticResource TextSize}"
                                Tag="HMC - Lag Time.png" ToolTipService.ToolTip="Click here for help on Lag Time" Click="ButtonHelp_Click"/>
                    </StackPanel>
                    <TextBox x:Name="TextBoxLagTime" Grid.Row="3" Grid.Column="1" Width="50"/>
                    <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="2" HorizontalAlignment="Right">
                        <TextBlock Text="Lead Time"/>
                        <Button Content="?" Margin="2,0,0,0" Template="{StaticResource RoundButtonTemplate}" Background="{StaticResource BlueRadialGradientBrush}" Foreground="#FFFFFF" Width="18" Height="18" FontWeight="Bold" FontSize="{StaticResource TextSize}"
                                Tag="HMC - Lead Time.png" ToolTipService.ToolTip="Click here for help on Lead Time" Click="ButtonHelp_Click"/>
                    </StackPanel>
                    <TextBox x:Name="TextBoxLeadTime" Grid.Row="3" Grid.Column="3" Width="50"/>

                    <TextBlock Text="Frequency Range Min" Grid.Row="4" Grid.Column="0"/>
                    <TextBox x:Name="TextBoxFrequencyRangeMin" Grid.Row="4" Grid.Column="1" Width="50"/>
                    <TextBlock Text="Frequency Range Max" Grid.Row="4" Grid.Column="2"/>
                    <TextBox x:Name="TextBoxFrequencyRangeMax" Grid.Row="4" Grid.Column="3" Width="50"/>

                    <TextBlock Text="Chart Refresh Interval (in miliseconds)" Grid.Row="5" Grid.Column="0"/>
                    <TextBox x:Name="TextBoxChartRefreshInterval" Grid.Row="5" Grid.Column="1" Width="50"/>
                    <TextBlock Text="Statistic Data Refresh Interval (in seconds)" Grid.Row="5" Grid.Column="2"/>
                    <TextBox x:Name="TextBoxStatisticDataRefreshInterval" Grid.Row="5" Grid.Column="3" Width="50"/>

                    <TextBlock Text="Measurement Data Refresh Interval (in seconds)" Grid.Row="6" Grid.Column="0"/>
                    <TextBox x:Name="TextBoxMeasurementDataRefreshInterval" Grid.Row="6" Grid.Column="1" Width="50"/>
                    <CheckBox x:Name="CheckBoxForceIPv4" Content="Force IPv4" Grid.Row="6" Grid.Column="2"/>

                    <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2">
                        <CheckBox x:Name="CheckBoxUseLocalClockAsRealTime" Content="Use Local Clock as Real-time"/>
                        <Button Content="?" Margin="2,0,0,0" Template="{StaticResource RoundButtonTemplate}" Background="{StaticResource BlueRadialGradientBrush}" Foreground="#FFFFFF" Width="18" Height="18" FontWeight="Bold" FontSize="{StaticResource TextSize}"
                                Tag="HMC - Use Local Clock as RealTime.png" ToolTipService.ToolTip="Click here for help on Use Local Clock as Real-time" Click="ButtonHelp_Click"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="2">
                        <CheckBox x:Name="CheckBoxIgnoreBadTimestamps" Content="Ignore Bad Timestamps"/>
                        <Button Content="?" Margin="2,0,0,0" Template="{StaticResource RoundButtonTemplate}" Background="{StaticResource BlueRadialGradientBrush}" Foreground="#FFFFFF" Width="18" Height="18" FontWeight="Bold" FontSize="{StaticResource TextSize}"
                                Tag="HMC - Ignore Bad Timestamps.png" ToolTipService.ToolTip="Click here for help on Ignore Bad Timestamps" Click="ButtonHelp_Click"/>
                    </StackPanel>

                    <CheckBox x:Name="CheckBoxDisplayFrequencyYAxis" Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2" Content="Display Frequency Y-Axis"/>
                    <CheckBox x:Name="CheckBoxDisplayPhaseAngleYAxis" Grid.Row="8" Grid.Column="2" Grid.ColumnSpan="2" Content="Display Phase Angle Y-Axis"/>

                    <CheckBox x:Name="CheckBoxDisplayVoltageMagnitudeYAxis" Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2" Content="Display Voltage Magnitude Y-Axis"/>
                    <CheckBox x:Name="CheckBoxDisplayCurrentMagnitudeYAxis" Grid.Row="9" Grid.Column="2" Grid.ColumnSpan="2" Content="Display Current Magnitude Y-Axis"/>

                    <CheckBox x:Name="CheckBoxDisplayXAxis" Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" Content="Display X-Axis"/>
                    <CheckBox x:Name="CheckBoxDisplayLegend" Grid.Row="10" Grid.Column="2" Grid.ColumnSpan="2" Content="Display Legend"/>

                    <StackPanel Orientation="Horizontal" Grid.Row="11" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right">
                        <Button Content="Restore Default" Margin="0,0,5,0" Click="ButtonRestoreSettings_Click" Width="Auto"/>
                        <Button Content="Cancel" Margin="0,0,5,0" Click="ButtonCancel_Click" IsCancel="True"/>
                        <Button Content="Save" Click="ButtonSaveSettings_Click"/>
                    </StackPanel>

                </Grid>

            </Border>

        </tsf:TsfPopup>

        <!-- /Setting Popup XAML Ends -->

        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top">                        

            <StackPanel.Resources>
                
                <HierarchicalDataTemplate x:Key="MeasurementNodeTemplate">                    
                    
                    <StackPanel Orientation="Horizontal" Margin="-25,0,0,0" VerticalAlignment="Center">                        
                        <CheckBox IsChecked="{tsfBinding:Column Path=Selected}" IsEnabled="{tsfBinding:Column Path=Selectable}" ToolTip="{tsfBinding:Column Path=Description}" Height="Auto" 
                                  Foreground="{tsfBinding:Column Path=Foreground}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" VerticalAlignment="Center"/>
                        <Button Content="{tsfBinding:Column Path=SignalReference}" Template="{StaticResource HyperlinkStyleButtonTemplate}" ToolTip="{tsfBinding:Column Path=Description}" Height="Auto" Width="{tsfBinding:Column Path=MaximumSignalReferenceWidth}"
                                Click="ButtonMeasurement_Click"/>
                        <TextBlock Text="{tsfBinding:Column Path=Value}" Width="Auto"
                                   Foreground="{tsfBinding:Column Path=Quality, Converter={StaticResource StringToStatusColorConverter}}" ToolTip="{tsfBinding:Column Path=TimeTag}" HorizontalAlignment="Left" Margin="5,0,5,0"/>
                        <TextBlock Text="{tsfBinding:Column Path=EngineeringUnit}" Width="Auto"/>
                    </StackPanel>
                    
                </HierarchicalDataTemplate>
                
                <HierarchicalDataTemplate x:Key="DeviceNodeTemplate" ItemsSource="{tsfBinding:Column Path=MeasurementList}" ItemTemplate="{StaticResource MeasurementNodeTemplate}"> 
                    <StackPanel Orientation="Horizontal">
                        <Ellipse Width="12" Height="12" VerticalAlignment="Center" Fill="{tsfBinding:Column Path=StatusColor, Converter={StaticResource StringToStatusColorConverter}}"/>
                        <Button Content="{tsfBinding:Column Path=AcronymTruncated}" Tag="{tsfBinding:Column Path=Acronym}" Template="{StaticResource HyperlinkStyleButtonTemplate}" ToolTip="Click Here to Get Real-Time Statistics"
                                Height="Auto" Width="Auto" Click="ButtonGetStatistics_Click"/>
                        <Button Content="Edit" Tag="{tsfBinding:Column Path=Acronym}" Template="{StaticResource HyperlinkStyleButtonTemplate}" Height="Auto" Width="Auto" Click="ButtonEdit_Click"
                               />
                    </StackPanel>
                </HierarchicalDataTemplate>
                
                <HierarchicalDataTemplate x:Key="RootNodeTemplate" ItemsSource="{tsfBinding:Column Path=DeviceList}" ItemTemplate="{StaticResource DeviceNodeTemplate}">
                    
                    <StackPanel Orientation="Horizontal">
                        <Ellipse Width="12" Height="12" VerticalAlignment="Center" Fill="{tsfBinding:Column Path=StatusColor, Converter={StaticResource StringToStatusColorConverter}}"/>
                        <Button Content="{tsfBinding:Column Path=Acronym}" Tag="{tsfBinding:Column Path=Acronym}" Template="{StaticResource HyperlinkStyleButtonTemplate}" ToolTip="Click Here to Get Real-Time Statistics"
                                Height="Auto" Width="Auto" Click="ButtonGetStatistics_Click"/>
                        <Button Content="Edit" Tag="{tsfBinding:Column Path=Acronym}" Template="{StaticResource HyperlinkStyleButtonTemplate}" Height="Auto" Width="Auto" Click="ButtonEdit_Click"
                                Visibility="{tsfBinding:Column Path=ID, Converter={StaticResource ObjectToVisibilityConverter}}"/>
                    </StackPanel>
                    
                </HierarchicalDataTemplate>
                
                <Style x:Key="ExpandedItemStyle" TargetType="TreeViewItem">
                    <Setter Property="IsExpanded" Value="{tsfBinding:Column Path=Expanded}"/>
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="Black"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
                
            </StackPanel.Resources>
         
            <StackPanel Orientation="Horizontal" >
                <TextBlock Text="Refresh Interval: " />
                <TextBlock x:Name="TextBlockMeasurementRefreshInterval" />
                <TextBlock Text=" sec " />
                <TextBlock Text="{Binding Path=DataContext.LastRefresh, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl, AncestorLevel=1}}" />
            </StackPanel>
            
            <!-- Measurement Tree -->
            <TreeView ItemsSource="{tsfBinding:Column Path=ItemsSource}" ItemTemplate="{StaticResource RootNodeTemplate}" ItemContainerStyle="{StaticResource ExpandedItemStyle}" 
                      Height="615" Width="275" VerticalAlignment="Top" HorizontalAlignment="Left" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
                <TreeView.Resources>
                    <SolidColorBrush Color="White" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
                </TreeView.Resources>
            </TreeView>
            
        </StackPanel>

        <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Vertical" VerticalAlignment="Top" Margin="2">

            <!-- Top Buttons -->

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Template="{StaticResource HyperlinkStyleButtonTemplate}" Content="StatusFlag Reference" Width="Auto" Click="ButtonStatusBitReference_Click"/>
                <TextBlock Text="|"/>
                <Button Template="{StaticResource HyperlinkStyleButtonTemplate}" Content="Display Settings" Width="Auto" Click="ButtonManageSettings_Click"/>
                <TextBlock Text="|"/>
                <Button Template="{StaticResource HyperlinkStyleButtonTemplate}" Content="Save Display Settings" Width="Auto" Click="ButtonSave_Click"/>
                <TextBlock Text="|"/>
                <Button Template="{StaticResource HyperlinkStyleButtonTemplate}" Content="Load Display Settings" Width="Auto" Click="ButtonLoad_Click"/>
            </StackPanel>

            <!-- Chart -->

            <d3:ChartPlotter Name="ChartPlotterDynamic" Margin="2" Height="250" Width="555">

                <d3:InjectedPlotter Name="PhaseAnglePlotter" SetViewportBinding="False">
                    <d3:VerticalAxis Name="PhaseAngleYAxis" Placement="Left" />
                    <d3:VerticalAxisTitle Name="PhaseAngleAxisTitle" Content="Phase Angle" Placement="Left" />
                </d3:InjectedPlotter>

                <d3:InjectedPlotter Name="VoltagePlotter" SetViewportBinding="False">
                    <d3:VerticalAxis Name="VoltageYAxis" Placement="Right"/>
                    <d3:VerticalAxisTitle Name="VoltageAxisTitle" Content="Voltage" Placement="Right" />
                </d3:InjectedPlotter>

                <d3:InjectedPlotter Name="CurrentPlotter" SetViewportBinding="False">
                    <d3:VerticalAxis Name="CurrentYAxis" Placement="Right"/>
                    <d3:VerticalAxisTitle Name="CurrentAxisTitle" Content="Current" Placement="Right" />
                </d3:InjectedPlotter>

                <d3:AxisNavigation Placement="Bottom"/>
                <d3:AxisNavigation Placement="Right"/>

                <d3:VerticalAxisTitle Name="FrequencyAxisTitle" Content="Frequency" />

                <TextBlock x:Name="TextBlockLeft" Canvas.Left="2" Canvas.Bottom="0" />
                <TextBlock x:Name="TextBlockRight" Canvas.Right="2" Canvas.Bottom="0" />
                <TextBlock x:Name="ModeMessage" Canvas.Right="2" Canvas.Top="0" Text="Real-time" Visibility="{Binding Path=TemporalSupportEnabled, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}" />

            </d3:ChartPlotter>

            <!-- Historical Playback -->
            <Expander x:Name="ExpanderHistoricalPlayback" Header="Historical Playback" Visibility="{Binding Path=TemporalSupportEnabled, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}"
                      IsExpanded="{Binding Path=TemporalSupportEnabled, Mode=OneWay}" Collapsed="Expander_Collapsed" Expanded="Expander_Expanded">

                <Grid>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="2*"/>
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <TextBlock Text="Start Time" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right"/>
                    <TextBox x:Name="TextBoxStartTime" Grid.Row="0" Grid.Column="1" Text="{tsfBinding:Column Path=StartTime}"  Width="150"/>                 
                    <TextBlock Text="Stop Time" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right"/>
                    <TextBox x:Name="TextBoxStopTime" Grid.Row="0" Grid.Column="3" Text="{tsfBinding:Column Path=StopTime}" Width="150"/>
                    <TextBlock Text="Process Interval" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"/>
                    <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="5,0,0,0">
                        <Slider x:Name="SliderProcessInterval" Interval="250" Value="{Binding ElementName=TextBoxProcessInterval, Path=Text, Mode=TwoWay}" Margin="10,5,5,5" Minimum="0" Maximum="1000" TickFrequency="50" IsSnapToTickEnabled="True" Width="90"/>
                        <TextBox x:Name="TextBoxProcessInterval" Text="{Binding ElementName=SliderProcessInterval, Path=Value, Mode=TwoWay}" Width="50" VerticalAlignment="Center" TextAlignment="Center" TextChanged="TextBoxProcessInterval_TextChanged" />
                        <TextBlock Text="ms" Margin="0" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right">
                        <Button x:Name="ButtonStartPlayback" Content="Start Playback" Width="125" Click="ButtonStartPlayback_Click" Margin="0,0,5,0"/>    
                        <Button x:Name="ButtonReturnToRealtime" Content="Return to Real-time" Width="125" Click="ButtonReturnToRealtime_Click" Margin="0,0,5,0"/>
                    </StackPanel>

                </Grid>

            </Expander>

            <!-- Real-Time Data -->

            <sdk:DataGrid x:Name="DataGridCurrentValues" Margin="2" HorizontalAlignment="Left" Height="125" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto">

                <sdk:DataGrid.Columns>

                    <sdk:DataGridTextColumn Header="ID" IsReadOnly="True" Width="85" Binding="{tsfBinding:Column Path=ID}" ToolTipService.ToolTip="{tsfBinding:Column Path=Description}"
                                           CellStyle="{StaticResource CenterAlignCellStyle}" />
                    <sdk:DataGridTemplateColumn Header="Signal Reference" Width="144">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{tsfBinding:Column Path=SignalReference}" Foreground="{tsfBinding:Column Path=Foreground}" ToolTipService.ToolTip="{tsfBinding:Column Path=Description}" HorizontalAlignment="Left"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTextColumn Header="Time Tag" IsReadOnly="True" Width="100" Binding="{tsfBinding:Column Path=TimeTag}" CellStyle="{StaticResource CenterAlignCellStyle}"/>
                    <!--<sdk:DataGridTextColumn Header="Value" IsReadOnly="True" Width="90" Binding="{tsfBinding:Column Path=Value}" CellStyle="{StaticResource CenterAlignCellStyle}"
                                            Foreground="{Binding Quality, Converter={StaticResource StringToStatusColorConverter}}" />-->
                    
                    <sdk:DataGridTemplateColumn Header="Value" Width="95">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{tsfBinding:Column Path=Value}" Foreground="{Binding Quality, Converter={StaticResource StringToStatusColorConverter}}" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>

                    <sdk:DataGridTextColumn Header="Unit" IsReadOnly="True" Width="65" Binding="{tsfBinding:Column Path=EngineeringUnit}" CellStyle="{StaticResource CenterAlignCellStyle}"/>

                    <sdk:DataGridTemplateColumn Width="40">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button ToolTip="Remove Selected Measurement" Width="Auto" Padding="0" Click="ButtonRemove_Click">
                                    <Button.Template>
                                        <ControlTemplate>
                                            <Image Source="/GSF.TimeSeries.UI;component/images/Delete.png" Height="16" Width="16" />
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>

            </sdk:DataGrid>

            <!-- Real-Time Statistics -->

            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Run-time Statistics: " FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockDevice" Margin="0,0,25,0"/>
                <TextBlock Text="Refresh Interval: " Width="Auto"/>
                <TextBlock x:Name="TextBlockStatisticsRefreshInterval" Width="Auto"/>
                <TextBlock Text=" sec" Width="Auto"/>
            </StackPanel>

            <sdk:DataGrid x:Name="DataGridStatistics" Margin="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" HorizontalAlignment="Left" Height="190">

                <sdk:DataGrid.Columns>

                    <!--<sdk:DataGridTextColumn Header="ID" IsReadOnly="True" Width="75" Binding="{tsfBinding:Column Path=ID}" ToolTipService.ToolTip="{tsfBinding:Column Path=SignalReference}" CellStyle="{StaticResource CenterAlignCellStyle}"/>-->

                    <sdk:DataGridTemplateColumn Header="ID" Width="75" IsReadOnly="True">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{tsfBinding:Column Path=ID}" ToolTipService.ToolTip="{tsfBinding:Column Path=SignalReference}" HorizontalAlignment="Left"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    
                    
                    <sdk:DataGridTemplateColumn Header="Statistic" Width="180" IsReadOnly="True">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{tsfBinding:Column Path=StatisticName}" ToolTipService.ToolTip="{tsfBinding:Column Path=StatisticDescription}" HorizontalAlignment="Left"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>

                    <sdk:DataGridTemplateColumn Header="Value" Width="175" IsReadOnly="True">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{tsfBinding:Column Path=Value}" Foreground="{tsfBinding:Column Path=Quality, Converter={StaticResource StringToStatusColorConverter}}" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTextColumn Header="TimeTag" IsReadOnly="True" Width="100" Binding="{tsfBinding:Column Path=TimeTag}" CellStyle="{StaticResource CenterAlignCellStyle}"/>

                </sdk:DataGrid.Columns>

            </sdk:DataGrid>

        </StackPanel>
        
    </Grid>
    
</UserControl>
